from flask import request
from flask import Blueprint, render_template, redirect, url_for, flash
from python.model.user import User
from wtforms import StringField, PasswordField, SubmitField
from wtforms.validators import DataRequired, Email, EqualTo
from python.extensions import db, login_manager
import pymysql
from flask import jsonify


goods_bp = Blueprint('goods', __name__, url_prefix='/goods')
def get_conn():
    conn = pymysql.connect(host="localhost",
                           user="root",
                           password="123456",
                           database="stat", charset='utf8', )
    return conn
@goods_bp.route('/select_example',method=['GET','POST'])
def select_example():
    goods_list=db.session.query(Goods).all()
    test_goods_list=[]
    for good in goods_list:
        test_goods_list.append(
            {
                'a':good.a,
                'b':good.b,
                'c':good.c
            }
        )
    return jsonify(test_goods_list)